
import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_common/time_tool.dart';
import 'package:basic_team/memberdetail/member_detail_controller.dart';
import 'package:basic_widgets/app_bar_widget.dart';
import 'package:basic_widgets/bg_widget.dart';
import 'package:basic_widgets/image_widget.dart';
import 'package:basic_widgets/text_widget.dart';

class MemberDetailPage extends GetView<MemberDetailController> {
  const MemberDetailPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: backAppbar(title: "成员信息"),
      body: SingleChildScrollView(
        physics: AlwaysScrollableScrollPhysics(),
        child: Column(
          children: [
            headInfoWidget(),
            drInfoWidget(),
            Obx(
              () => personalInfoWidget(
                  title: '医生简介',
                  content: controller.doctorInfo.value.personalProfile ?? ''),
            ),
            personalInfoWidget(
                title: '擅长',
                content: controller.doctorInfo.value.excelAt ?? '')
          ],
        ),
      ),
    );
  }

  /// 头部信息
  Widget headInfoWidget() {
    return Obx(() => ListTile(
          leading: circleImg(
              width: 50,
              raduis: 4,
              head: controller.doctorInfo.value.profilePhoto ?? ''),
          title: Text(
            '${controller.doctorInfo.value.doctorNick ?? ''}',
            style: TextStyle(color: AppTheme.dartTextColor),
          ),
          subtitle: Text(
            '${controller.doctorInfo.value.titleName ?? ''}',
            style: TextStyle(color: AppTheme.dartWeakTextColor),
          ),
        ));
  }

  /// 医生信息
  Widget drInfoWidget() {
    return solidConnerContainer(
        width: ScreenHelper.screenWidth,
        height: ScreenHelper.height(170),
        margin: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
        padding: EdgeInsets.symmetric(
            vertical: ScreenHelper.width(10),
            horizontal: ScreenHelper.width(10)),
        child: SingleChildScrollView(
          physics: AlwaysScrollableScrollPhysics(),
          child: Column(
            children: [
              Padding(
                padding: EdgeInsets.all(ScreenHelper.width(4)),
                child: Obx(() => textItemWidget(
                    attrName: '成员编号',
                    fontSize: 16,
                    value: '${controller.doctorInfo.value.id ?? ''}',
                    valuColor: AppTheme.dartTextColor)),
              ),
              Obx(() => Padding(
                    padding: EdgeInsets.all(ScreenHelper.width(4)),
                    child: textItemWidget(
                      attrName: '联系电话',
                      fontSize: 16,
                      value: '${controller.doctorInfo.value.phone ?? ''}',
                      valuColor: AppTheme.dartTextColor,
                    ),
                  )),
              Obx(
                () => Padding(
                  padding: EdgeInsets.all(ScreenHelper.width(4)),
                  child: textItemWidget(
                    attrName: '签约人数',
                    fontSize: 16,
                    value: '${controller.signCount.value ?? '0'}',
                  ),
                ),
              ),
              // Padding(
              //   padding: EdgeInsets.all(ScreenHelper.width(4)),
              //   child: textItemWidget(
              //     attrName: '医生评分',
              //     fontSize: 16,
              //     value: '60',
              //   ),
              // ),
          Obx(() =>     Padding(
                padding: EdgeInsets.all(ScreenHelper.width(4)),
                child: textItemWidget(
                  attrName: '加入时间',
                  fontSize: 16,
                  value:TimeTool.strToDate(controller.doctorInfo!=null&&controller.doctorInfo.value.createTime!=null?controller.doctorInfo.value.createTime!:"")
                ),
              ))
            ],
          ),
        ),
        bgColor: Colors.white);
  }

  Widget personalInfoWidget({required String title, required String content}) {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: ScreenHelper.height(15)),
      padding: EdgeInsets.all(ScreenHelper.width(6)),
      child: ListTile(
          title: Text(
            title,
            style: TextStyle(
                color: AppTheme.dartTextColor, fontSize: ScreenHelper.sp(18)),
          ),
          subtitle: Padding(
            padding: EdgeInsets.only(top: ScreenHelper.height(10)),
            child: Text(
              "${content}",
              style: TextStyle(height: 1.6),
            ),
          )),
    );
  }
}
